package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.entity.Setmeal;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface SetmealMapper {
    /**
     * 根据菜品id查询套餐
     * @return
     */
    @Select("select setmeal_id from setmeal_dish where dish_id = #{dishId}")
    Long findDishByDishId(Long dishId);

    /**
     * 根据分类id查询套餐
     * @param categoryId
     * @return
     */
    Page<SetmealVO> findSetmealByCategoryIdAndNameAndStatus(Long categoryId, String name, Integer status);

    /**
     * 插入套餐数据
     * @param setmeal
     */
    void insert(Setmeal setmeal);

    /**
     * 根据id查询套餐数据
     * @param id
     * @return
     */
    @Select("select * from setmeal where id = #{id}")
    Setmeal findDishBySetmealId(Long id);

    /**
     * 批量删除套餐数据
     * @param ids
     */
    void deleteBatch(List<Long> ids);

    /**
     * 修改套餐状态
     */
    @Update("update setmeal set status = #{status} where id = #{id}")
    void updateStatusBySetmealId(Integer status, Long id);

    @Select("select * from setmeal where id = #{id}")
    Setmeal findSetmealById(Long id);

    void update(Setmeal setmeal);
}
